<template>
  <div class="scan-deatil mx5">
    <div>
      <el-tabs v-model="activeName" class="demo-tabs" style="display: inline">
        <el-form
          label-suffix="："
          :model="saveValue"
          :rules="rules"
          ref="formRef"
          :disabled="readonly"
          label-width="170px"
        >
          <template v-if="props?.type !== '1'">
            <el-tab-pane label="采集周期" name="first">
              <el-form-item
                label="扫描频率"
                prop="scanCycleType"
                :disabled="saveValue.canUpdate === false"
              >
                <el-radio-group
                  v-model="saveValue.scanCycleType"
                  :disabled="saveValue.canUpdate === false"
                >
                  <el-radio :label="1">单次扫描</el-radio>
                  <el-radio :label="2">定期扫描</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-row v-if="saveValue.scanCycleType == 2">
                <el-col :span="7">
                  <el-form-item label="执行周期" prop="scanCycle">
                    <el-select
                      :disabled="saveValue.canUpdate === false"
                      placeholder="频次"
                      class="mr5"
                      v-model="saveValue.scanCycle"
                      @change="resetData"
                      clearable
                    >
                      <el-option key="1" label="每月" value="month" />
                      <el-option key="2" label="每周" value="week" />
                      <el-option key="3" label="每日" value="day" />
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="3" v-if="saveValue.scanCycle != 'day' && saveValue.scanCycle != ''"
                  ><el-form-item prop="scanCycleNum" label-width="0px">
                    <el-select
                      :disabled="saveValue.canUpdate === false"
                      clearable
                      placeholder="日期"
                      style="width: 100px"
                      class="mr5"
                      v-model="saveValue.scanCycleNum"
                      v-if="saveValue.scanCycle == 'week'"
                    >
                      <el-option
                        v-for="item in dateList.week"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                      />
                    </el-select>
                    <el-select
                      :disabled="saveValue.canUpdate === false"
                      clearable
                      placeholder="日期"
                      style="width: 100px"
                      class="mr5"
                      v-model="saveValue.scanCycleNum"
                      v-if="saveValue.scanCycle == 'month'"
                    >
                      <el-option
                        v-for="item in dateList.month"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                      /> </el-select></el-form-item
                ></el-col>
                <el-col :span="6">
                  <el-form-item prop="scanCycleTime" label-width="0px"
                    ><el-time-picker
                      v-model="saveValue.scanCycleTime"
                      :disabled="saveValue.canUpdate === false"
                      arrow-control
                      placeholder="请选择时间"
                      value-format="YYYY-MM-DD HH:mm:ss" /></el-form-item
                ></el-col>
              </el-row>
              <template v-if="saveValue.scanCycleType == 2">
                <el-form-item label="开始时间" prop="taskStartTime">
                  <el-date-picker
                    :disabled="saveValue.canUpdate === false"
                    v-model="saveValue.taskStartTime"
                    type="date"
                    placeholder="请选择开始时间"
                    format="YYYY-MM-DD"
                    value-format="YYYY-MM-DD HH:mm:ss"
                  />
                </el-form-item>
                <el-form-item label="结束时间" prop="taskEndTime">
                  <el-date-picker
                    :disabled="saveValue.canUpdate === false"
                    v-model="saveValue.taskEndTime"
                    type="date"
                    placeholder="请选择结束时间"
                    format="YYYY-MM-DD"
                    value-format="YYYY-MM-DD HH:mm:ss"
                  />
                </el-form-item>
              </template>
              <el-form-item
                label="执行方式"
                v-if="saveValue.scanCycleType == 1"
                prop="scanCycleMethod"
              >
                <el-radio-group
                  v-model="saveValue.scanCycleMethod"
                  :disabled="saveValue.canUpdate === false"
                >
                  <el-radio :label="1">立即执行</el-radio>
                  <el-radio :label="2">手动执行</el-radio>
                  <el-radio :label="3">指定时间</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item
                label="选择时间"
                v-if="saveValue.scanCycleMethod == 3 && saveValue.scanCycleType == 1"
                prop="scanCycleTime"
              >
                <el-date-picker
                  :disabled="saveValue.canUpdate === false"
                  clearable
                  v-model="saveValue.scanCycleTime"
                  type="datetime"
                  placeholder="请选择日期"
                  value-format="YYYY-MM-DD HH:mm:ss"
                  :disabled-hours="disabledHours"
                  :disabled-minutes="disabledMinutes"
                  :disabled-seconds="disabledSeconds"
                  :disabled-date="disabledDate"
                  :default-time="new Date()"
                />
              </el-form-item>
              <el-form-item v-if="saveValue.canUpdate === false">
                <Icon icon="svg-icon:tips" />
                <span style="color: #cccccc">{{ saveValue.canNotUpdateDescribe || '' }}</span>
              </el-form-item>
            </el-tab-pane>
            <el-tab-pane
              label="数据库采集策略"
              name="second"
              v-if="props?.params.type === '0' || props?.dataType === 'db'"
            >
              <!-- <el-form-item label="占用带宽上限" prop="field10">
                <el-input-number
                  style="width: 50%; margin-right: 10px"
                  v-model="saveValue.field10"
                  clearable
                  placeholder="请输入占用带宽上限"
                  :min="1"
                  :max="9999"
                />
                MB/S
              </el-form-item>
              <el-form-item label="CPU最高并发数上限" prop="field11">
                <el-input-number
                  style="width: 50%"
                  v-model="saveValue.field11"
                  clearable
                  placeholder="请输入CPU最高并发数上限"
                  :min="1"
                  :max="10"
                />
              </el-form-item>
              <el-form-item label="抽样保存百分比" prop="field12">
                <el-input-number
                  style="width: 50%; margin-right: 10px"
                  v-model="saveValue.field12"
                  clearable
                  placeholder="请输入抽样保存百分比"
                  :min="0"
                  :max="100"
                />%
              </el-form-item>
              <el-form-item label="是否启用二进制扫描" prop="field13">
                <el-radio-group v-model="saveValue.field13">
                  <el-radio label="1">是</el-radio>
                  <el-radio label="0">否</el-radio>
                </el-radio-group>
              </el-form-item> -->
              <el-form-item label="是否扫描数据内容" prop="scanSamples">
                <el-radio-group v-model="saveValue.scanSamples">
                  <el-radio :label="1">是</el-radio>
                  <el-radio :label="0">否</el-radio>
                </el-radio-group>
              </el-form-item>
              <div v-if="saveValue.scanSamples == 1">
                <el-form-item label="抽样行数" prop="scanSamplesLine">
                  <ns-input
                    v-model.number="saveValue.scanSamplesLine"
                    style="width: 30%"
                    clearable
                    placeholder="请输入抽样行数"
                  />
                </el-form-item>
                <el-form-item label="抽样方式" prop="scanSamplesType">
                  <el-radio-group v-model="saveValue.scanSamplesType">
                    <el-radio :label="0">正序抽样</el-radio>
                    <el-radio :label="1">倒序抽样</el-radio>
                  </el-radio-group>
                </el-form-item>
              </div>
            </el-tab-pane>
            <el-tab-pane
              label="文件服务器采集策略"
              name="third"
              v-if="props?.params.type === '1' || props?.dataType === 'file'"
            >
              <!-- <el-form-item label="占用带宽上限" prop="field10">
                <el-input-number
                  style="width: 50%; margin-right: 10px"
                  v-model="saveValue.field10"
                  clearable
                  placeholder="请输入占用带宽上限"
                  :min="1"
                  :max="9999"
                />
                MB/S
              </el-form-item>
              <el-form-item label="CPU最高并发数上限" prop="field11">
                <el-input-number
                  style="width: 50%"
                  v-model="saveValue.field11"
                  clearable
                  placeholder="请输入CPU最高并发数上限"
                  :min="1"
                  :max="10"
                />
              </el-form-item>
              <el-form-item label="最大扫描文件数" prop="field14">
                <el-input-number
                  style="width: 50%; margin-right: 10px"
                  v-model="saveValue.field14"
                  clearable
                  placeholder="请输入最大扫描文件数"
                  :min="0"
                />
              </el-form-item>
              <el-form-item label="扫描日期范围" prop="field16" style="width: 50%">
                <el-date-picker
                  v-model="saveValue.field16"
                  type="datetimerange"
                  range-separator="到"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                  format="YYYY-MM-DD HH:mm:ss"
                  value-format="YYYY-MM-DD HH:mm:ss"
                />
              </el-form-item>
              <el-form-item label="是否增量扫描" prop="field15">
                <el-radio-group v-model="saveValue.field15">
                  <el-radio label="1">是</el-radio>
                  <el-radio label="0">否</el-radio>
                </el-radio-group>
              </el-form-item> -->
              <el-form-item label="按文件大小过滤" prop="fileSize">
                <ns-input
                  style="width: 200px"
                  v-model="saveValue.fileSize"
                  clearable
                  placeholder="请输入文件大小"
                  @input="(value) => handleInput(value, 'fileSize')"
                />
                <span class="ml2">单位（M）</span>
                <Icon class="ml5" icon="svg-icon:tips" />
                <span style="color: #cccccc">超过设置大小的文件将被忽略，"0"为不过滤</span>
              </el-form-item>
              <el-form-item label="扫描文件类型" prop="fileType">
                <el-radio-group v-model="saveValue.fileType">
                  <el-radio :label="'1'">全部</el-radio>
                  <el-radio :label="'2'">指定类型</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="文件类型" v-if="saveValue.fileType == '2'" prop="fileScanClass">
                <el-select
                  multiple
                  filterable
                  clearable
                  allow-create
                  default-first-option
                  v-model="saveValue.fileScanClass"
                  placeholder="请选择或输入文件类型"
                  style="width: 50%"
                >
                  <el-option
                    v-for="item in fileType"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
            </el-tab-pane>
          </template>
          <el-tab-pane label="分类分级策略" name="fourth">
            <el-form-item label="数据标准" prop="markedTemplateId">
              <el-select
                v-model="saveValue.markedTemplateId"
                clearable
                @change="getModelList"
                filterable
              >
                <el-option
                  v-for="item in markedTemplateInfo"
                  :label="item.dataStandardName"
                  :value="item.id"
                  :key="item.id"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="是否分类分级" prop="marked">
              <el-radio-group v-model="saveValue.marked">
                <el-radio label="1">是</el-radio>
                <el-radio label="0">否</el-radio>
              </el-radio-group>
            </el-form-item>
            <div v-if="saveValue.marked == '1'">
              <el-form-item label="数据打标方式" prop="isDataMark">
                <el-row :gutter="24" style="width: 100%">
                  <el-col :span="3" class="mb6">
                    <el-checkbox
                      style="display: inline"
                      label="rule"
                      true-label="1"
                      false-label="0"
                      class="pr5"
                      key="rule"
                      v-model="saveValue.ruleMark"
                      :disabled="!(props?.params.type !== '0' && props?.dataType !== 'db')"
                      >规则打标</el-checkbox
                    >
                  </el-col>
                  <el-col :span="21" v-if="props?.params.type !== '0' && props?.dataType !== 'db'">
                    <el-form-item
                      v-if="saveValue.ruleMark == '1'"
                      label="优先级"
                      label-width="110px"
                      :prop="saveValue.ruleMark == '1' ? 'rulePriority' : ''"
                    >
                      <ns-input
                        style="display: inline; width: 200px"
                        placeholder="请输入优先级"
                        v-model="saveValue.rulePriority"
                        clearable
                        @input="(value) => handleInput(value, 'rulePriority')"
                      />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row
                  :gutter="24"
                  style="width: 100%"
                  v-if="props?.params.type !== '0' && props?.dataType !== 'db'"
                >
                  <el-col :span="3" class="mb6">
                    <el-checkbox
                      style="display: inline"
                      label="module"
                      class="pr5"
                      key="module"
                      true-label="1"
                      false-label="0"
                      v-model="saveValue.moduleMark"
                      >机器学习模型</el-checkbox
                    >
                  </el-col>
                  <el-col :span="7">
                    <el-form-item
                      v-if="saveValue.moduleMark == '1'"
                      label="优先级"
                      label-width="110px"
                      :prop="saveValue.moduleMark == '1' ? 'modulePriority' : ''"
                    >
                      <ns-input
                        style="display: block; width: 100%"
                        placeholder="请输入优先级"
                        v-model="saveValue.modulePriority"
                        clearable
                        @input="(value) => handleInput(value, 'modulePriority')"
                      />
                    </el-form-item>
                  </el-col>
                  <el-col :span="10">
                    <el-form-item
                      label="机器学习模型"
                      :prop="saveValue.moduleMark == '1' ? 'moduleId' : ''"
                      label-width="140px"
                      v-if="saveValue.moduleMark == '1'"
                    >
                      <el-select
                        style="display: inline-block; width: 200px"
                        placeholder="请选择机器学习模型"
                        v-model="saveValue.moduleId"
                        clearable
                      >
                        <el-option
                          v-for="item in machineModel"
                          :label="item.name"
                          :value="item.id"
                          :key="item.id"
                        />
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row
                  :gutter="24"
                  style="width: 100%"
                  v-if="props?.params.type !== '0' && props?.dataType !== 'db'"
                >
                  <el-col :span="3">
                    <el-checkbox
                      style="display: inline"
                      label="file"
                      key="file"
                      class="pr5"
                      true-label="1"
                      false-label="0"
                      v-model="saveValue.fileMark"
                      >文件相似度</el-checkbox
                    >
                  </el-col>
                  <el-col :span="7">
                    <el-form-item
                      v-if="saveValue.fileMark == '1'"
                      label="优先级"
                      label-width="110px"
                      :prop="saveValue.fileMark == '1' ? 'filePriority' : ''"
                    >
                      <ns-input
                        style="display: inline; width: 200px"
                        placeholder="请输入优先级"
                        v-model="saveValue.filePriority"
                        clearable
                        @input="(value) => handleInput(value, 'filePriority')"
                      />
                    </el-form-item>
                  </el-col>
                  <el-col :span="14">
                    <el-form-item
                      label="相似度指纹算法"
                      :prop="saveValue.fileMark == '1' ? 'likeSignAlgo' : ''"
                      label-width="140px"
                      v-if="saveValue.fileMark == '1'"
                    >
                      <el-checkbox-group v-model="saveValue.likeSignAlgo" style="display: inline">
                        <el-checkbox label="MD5" />
                        <el-checkbox label="KFS" />
                        <el-checkbox label="PFS" />
                        <el-checkbox label="PSA" />
                      </el-checkbox-group>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter="24" style="width: 100%">
                  <el-col :span="3" />
                  <el-col :span="21">
                    <el-form-item
                      label="相似度阈值"
                      label-width="110px"
                      :prop="saveValue.fileMark == '1' ? 'likeThreshold' : ''"
                      v-if="saveValue.fileMark == '1'"
                    >
                      <ns-input
                        style="display: inline; width: 123px"
                        v-model="saveValue.likeThreshold"
                        class="mr2"
                        clearable
                        @input="
                          saveValue.likeThreshold = saveValue.likeThreshold.replace(
                            /^0+(\d)|[^\d]+/g,
                            ''
                          )
                        "
                      />
                      百分比
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-form-item>
              <el-form-item
                label="是否保存未匹配文件"
                prop="isSaveResult"
                v-if="props?.params.type !== '0' && props?.dataType !== 'db'"
              >
                <el-radio-group v-model="saveValue.isSaveResult">
                  <el-radio :label="0">否</el-radio>
                  <el-radio :label="1">是</el-radio>
                </el-radio-group>
              </el-form-item>
            </div>
          </el-tab-pane>
        </el-form>
      </el-tabs>
    </div>
    <div class="" v-if="!readonly">
      <el-button type="primary" @click="save">确定</el-button>
      <el-button @click="closeOutDrawer">取消</el-button>
    </div>
  </div>
</template>

<script lang="ts" setup>
import * as scanStrategyApi from '@/api/asset/scanStrategy/index'
import { ElMessage } from 'element-plus'
import { dateList, fileType, valiList } from '@/utils/dict'
import dayjs from 'dayjs'
import { dataStandardsPage } from '@/api/dataStandards/standards/index'
import { mapModelList } from '@/api/machineModel/classModel'
import en from '@/locales/en'
const activeName = ref('first')
const formRef = ref()
const markedTemplateInfo = ref()
const machineModel = ref([])
const props = defineProps({
  params: {
    type: Object,
    default: () => {}
  },
  readonly: {
    type: Boolean,
    default: false
  },
  type: {
    type: String
  },
  dataType: {
    type: String
  },
  closeOutDrawer: Function
})

const getModelList = (id) => {
  mapModelList({ dataStandardId: id, page: 1, pageSize: 10000 }).then(({ data }) => {
    machineModel.value = data
    saveValue.value.moduleId = machineModel.value[0]?.id || ''
  })
}

//限制只能输入数字
function handleInput(value, key) {
  const filteredValue = value.replace(/[^0-9]/g, '')

  if (filteredValue !== saveValue.value[key]) {
    saveValue.value[key] = filteredValue
  }
}

/**
 * @description:获取数据，并赋值扫描文件类型
 */
onMounted(() => {
  console.log(`props.params -->`, props.params)
  if (props.params) {
    scanStrategyApi.getScanPolicyTemplate(props.params.id).then((res) => {
      updateData(res)
    })
  }
  if (props.type === '1') {
    activeName.value = 'fourth'
  }
  //获取数据标准
  dataStandardsPage({
    page: 1,
    pageSize: 10000,
    type: props.dataType == 'db' || props?.params.type === '0' ? 1 : 0,
    status: '1'
  }).then((res) => {
    markedTemplateInfo.value = res.data
    console.log(`markedTemplateInfo.value -->`, markedTemplateInfo.value)
  })
})
watch(
  () => props.params,
  (val) => {
    updateData(val)
  }
)
watch(
  () => props.type,
  (val) => {
    if (val == '1') {
      activeName.value = 'fourth'
    } else if (val == '0') {
      activeName.value = 'first'
    }
  }
)
const updateData = (res) => {
  console.log(`res -->`, res)
  for (let i in res) {
    saveValue.value[i] = res[i]
  }
  saveValue.value.ruleMark =
    props?.params.type !== '0' && props?.dataType !== 'db' ? saveValue.value.ruleMark : '1'

  if (props?.params.type === '1' || props?.dataType === 'file') {
    saveValue.value.field16 = [saveValue.value.field16, saveValue.value.field17]
  }
  if (saveValue.value.markedTemplateId) {
    mapModelList({
      dataStandardId: saveValue.value.markedTemplateId,
      page: 1,
      pageSize: 10000
    }).then(({ data }) => {
      machineModel.value = data
    })
  }
}
/**
 * @description: 定义数据打标方式校验规则
 * @param {*} rule
 * @param {*} value
 * @param {*} callback
 */

/**
 * @description:限制选择当天之前的日
 * @param {*} time
 * @return Boolean
 */
const disabledDate = (time) => {
  return time.getTime() < Date.now() - 8.64e7
} /**
 * @description:限制选择此刻之前的时，下面分别是分和秒
 * @return {*}
 */
const disabledHours = () => {
  const a = []
  for (let i = 0; i < 24; i++) {
    // 限制之前 < 之后 >
    if (new Date().getHours() <= i) continue
    a.push(i)
  }
  return a
}
const disabledMinutes = () => {
  const a = []
  for (let i = 0; i < 60; i++) {
    // 限制之前 < 之后 >
    if (new Date().getMinutes() <= i) continue
    a.push(i)
  }
  return a
}
const disabledSeconds = () => {
  const a = []
  for (let i = 0; i < 60; i++) {
    // 限制之前 < 之后 >
    if (new Date().getSeconds() <= i) continue
    a.push(i)
  }
  return a
}
const validateTime = (rule: any, value: any, callback: any) => {
  if (saveValue.value.taskStartTime && saveValue.value.taskEndTime) {
    const start = Date.parse(new Date(saveValue.value.taskStartTime).toString())
    const end = Date.parse(new Date(saveValue.value.taskEndTime).toString())
    if (rule.field == 'taskStartTime' || rule.fullField == 'taskStartTime') {
      if (start > end) {
        callback(new Error('开始时间不能大于结束时间'))
      } else {
        callback()
      }
    } else if (rule.field == 'taskEndTime' || rule.fullField == 'taskEndTime') {
      if (start > end) {
        callback(new Error('结束时间不能小于开始时间'))
      } else {
        callback()
      }
    }
  } else {
    callback()
  }
}
const validatePass = (rule: any, value: any, callback: any) => {
  if (
    (saveValue.value.moduleMark === '0' || saveValue.value.moduleMark === null) &&
    (saveValue.value.fileMark === '0' || saveValue.value.fileMark === null) &&
    (saveValue.value.ruleMark === '0' || saveValue.value.ruleMark === null)
  ) {
    callback(new Error('请选择数据打标方式'))
  } else {
    callback()
  }
}
const resetData = () => {
  saveValue.value.scanCycleNum = 1
}
const validateRule = (rule: any, value: any, callback: any) => {
  if (
    saveValue.value.fileMark == '1' &&
    saveValue.value.filePriority == saveValue.value.rulePriority &&
    saveValue.value.rulePriority != ''
  ) {
    callback(new Error('优先级不能相同'))
  } else if (
    saveValue.value.moduleMark == '1' &&
    saveValue.value.modulePriority == saveValue.value.rulePriority &&
    saveValue.value.rulePriority != ''
  ) {
    callback(new Error('优先级不能相同'))
  } else if (saveValue.value.ruleMark && saveValue.value.rulePriority == '') {
    callback(new Error('请输入优先级'))
  } else {
    callback()
  }
}
const validatemodule = (rule: any, value: any, callback: any) => {
  if (
    saveValue.value.fileMark == '1' &&
    saveValue.value.filePriority == saveValue.value.modulePriority &&
    saveValue.value.modulePriority != ''
  ) {
    callback(new Error('优先级不能相同'))
  } else if (
    saveValue.value.ruleMark == '1' &&
    saveValue.value.rulePriority == saveValue.value.modulePriority &&
    saveValue.value.modulePriority != ''
  ) {
    callback(new Error('优先级不能相同'))
  } else if (saveValue.value.moduleMark && saveValue.value.modulePriority == '') {
    callback(new Error('请输入优先级'))
  } else {
    callback()
  }
}
const validateFile = (rule: any, value: any, callback: any) => {
  if (
    saveValue.value.moduleMark == '1' &&
    saveValue.value.modulePriority == saveValue.value.filePriority &&
    saveValue.value.filePriority != ''
  ) {
    callback(new Error('优先级不能相同'))
  } else if (
    saveValue.value.ruleMark == '1' &&
    saveValue.value.rulePriority == saveValue.value.filePriority &&
    saveValue.value.filePriority != ''
  ) {
    callback(new Error('优先级不能相同'))
  } else if (saveValue.value.fileMark && saveValue.value.filePriority == '') {
    callback(new Error('请输入优先级'))
  } else {
    callback()
  }
}
const save = () => {
  formRef.value.validate((val, prop) => {
    for (let item in prop) {
      if (valiList.cycle.indexOf(item) > -1) {
        activeName.value = 'first'
      } else if (valiList.dataStrategy.indexOf(item) > -1) {
        activeName.value = 'second'
      } else if (valiList.fileStrategy.indexOf(item) > -1) {
        activeName.value = 'third'
      } else if (valiList.classification.indexOf(item) > -1) {
        activeName.value = 'fourth'
      }
    }
    if (val) {
      saveValue.value.likeThreshold = Number(saveValue.value.likeThreshold)
      if (props?.params.type === '1' || props?.dataType === 'file') {
        saveValue.value.field17 = saveValue.value.field16[1]
        saveValue.value.field16 = saveValue.value.field16[0]
      }
      saveValue.value.rulePriority =
        props?.params.type !== '0' && props?.dataType !== 'db' ? saveValue.value.rulePriority : '1'
      scanStrategyApi
        .updateScanPolicyTemplate({ ...saveValue.value, id: props.params.id })
        .then((res) => {
          res && ElMessage.success('编辑成功')
          res && props.params.callBack()
          res && props.closeOutDrawer()
        })
    }
  })
}
const saveValue = ref({
  scanCycleTime: 0,
  scanCycleNum: 1,
  markedTemplateId: '',
  scanCycle: 'month',
  templateName: '',
  scanCycleMethod: 1,
  templateDesc: '',
  templateType: '0',
  status: 0,
  marked: '1',
  scanCycleType: 1,
  dbScanType: 0,
  scanSamples: 1,
  scanSamplesLine: 10,
  scanSamplesType: 0,
  fileScanType: 0,
  fileSize: 0,
  likeThreshold: 0,
  likeSignAlgo: [],
  priority: '',
  moduleId: '',
  filePriority: '',
  modulePriority: '',
  rulePriority: '',
  fileScanClass: [],
  ruleMark: '0',
  moduleMark: '0',
  fileMark: '0',
  fileType: '1',
  isDataMark: '',
  isSaveResult: 1,
  taskStartTime: '',
  taskEndTime: '',
  field10: 2365,
  field11: 6,
  field12: 23,
  field13: '0',
  field14: undefined,
  field15: '0',
  field16: '',
  field17: ''
})
const rules = ref({
  scanCycle: [{ required: true, message: '请选择执行周期', trigger: 'change' }],
  scanCycleType: [{ required: true, message: '请选择扫描频率', trigger: 'change' }],
  scanCycleNum: [{ required: true, message: '请选择日期', trigger: 'change' }],
  scanCycleMethod: [{ required: true, message: '请选择执行方式', trigger: 'change' }],
  // dbScanType: [{ required: true, message: '请选择数据库采集方式', trigger: 'change' }],
  scanSamples: [{ required: true, message: '请选择是否扫描数据内容', trigger: 'change' }],
  scanSamplesLine: [{ required: true, message: '请选择抽样行数', trigger: 'change' }],
  scanSamplesType: [{ required: true, message: '请选择抽样方式', trigger: 'change' }],
  // fileScanType: [{ required: true, message: '请选择文件采集方式', trigger: 'change' }],
  fileSize: [{ required: true, message: '请输入文件过滤大小', trigger: 'blur' }],
  fileScanClass: [{ required: true, message: '请选择扫描文件类型', trigger: 'change' }],
  marked: [{ required: true, message: '请选择是否分类分级', trigger: 'change' }],
  likeSignAlgo: [{ required: true, message: '请选择相似度指纹算法', trigger: 'change' }],
  scanCycleTime: [{ required: true, message: '请选择时间', trigger: 'change' }],
  markedTemplateId: [{ required: true, message: '请选择数据标准', trigger: 'change' }],
  rulePriority: [{ validator: validateRule, required: true, trigger: 'blur' }],
  filePriority: [{ validator: validateFile, required: true, trigger: 'blur' }],
  modulePriority: [{ validator: validatemodule, required: true, trigger: 'blur' }],
  moduleId: [{ required: true, message: '请选择机器模型算法', trigger: 'change' }],
  fileType: [{ required: true, message: '请选择扫描文件类型', trigger: 'change' }],
  likeThreshold: [{ required: true, message: '请输入相似度阈值', trigger: 'blur' }],
  isDataMark: [{ validator: validatePass, trigger: 'change', required: true }],
  isSaveResult: [{ required: true, message: '请选择是否匹配未保存文件', trigger: 'change' }],
  taskStartTime: [{ required: false, validator: validateTime, trigger: 'change' }],
  taskEndTime: [{ required: false, validator: validateTime, trigger: 'change' }]
})
</script>

<style lang="scss">
.scan-deatil {
  .el-form-item {
    margin-bottom: 20px;
  }
}
</style>
